All Questions
27 questions
3votes
1answer
561views
Finding the minimum element of a stack of numbers
As part of an online programming challenge, I wrote a program that implements a stack of integers, supporting adding and removing elements, finding the last inserted element, and the minimum element. ...
5votes
4answers
552views
LeetCode: Roman to Integer in Java
I tried solve this easy leetcode challenge in java. Challenge link Here is my solution ...
9votes
3answers
4kviews
Find the smallest positive integer that is absent from a given array
I made the acquaintance of big-O a couple of weeks ago and am trying to get to grips with it, but although there's a lot of material out there about calculating time complexity, I can't seem to find ...
4votes
3answers
426views
Find the first missing positive integer in an array of integers
The problem is the one explained in Given an unsorted integer array, find the first missing positive integer Given an unsorted integer array, find the first missing positive integer. For ...
3votes
1answer
6kviews
"Counter Game" Powers of 2 Game
I have been working on this hackerrank problem: Louise and Richard have developed a numbers game. They pick a number (1 ≤ n < 264) and check to see if it is a power of 2. If it is, they divide ...
4votes
1answer
1kviews
Time complexity of Max counters
As per the instructions are given in MaxCounters-Codility, You are given N counters, initially set to 0, and you have two possible operations on them: <...
3votes
2answers
522views
Non repeating character in Java
Given a string s consisting of lowercase Latin Letters, find the first non repeating character in s. Input: The first line contains T denoting the number of testcases. Then follows ...
1vote
2answers
962views
Star Elements implementation in Java
Given an unsorted array. The task is to find all the star and super star elements in the array. Star are those elements which are strictly greater than all the elements on its right side. Super ...
2votes
2answers
503views
Greater on the right side in Java
Given an array of integers, replace every element with the next greatest element (greatest element on the right side) in the array. Since there is no element next to the last element, replace it ...
2votes
2answers
7kviews
Program to shorten URL and decode it back to get original URL
TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/design-tinyurl and it returns a short URL. Design the encode and ...
2votes
1answer
721views
Max Increase to Keep City Skyline in Java
In a 2-dimensional array grid, each value grid[i][j] represents the height of a building located there. We are allowed to increase the height of any number of buildings, by any amount (the amounts can ...
0votes
2answers
608views
Pancake sort inteview using java
Given an array of integers arr: Write a function flip(arr, k) that reverses the order of the first k elements in the array <...
5votes
2answers
2kviews
Merge non overlapping intervals
Merge Intervals Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initially sorted according to their ...
2votes
4answers
2kviews
Reverse the digits of an Integer
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Return 0 if the result overflows and does not fit in a 32 bit signed integer This is my approach: <...
1vote
1answer
2kviews
Hackerrank "Breaking the Record" solution
I have solved the hacker rank problem listed here. Given a sequence of scores, I need to count the number of times the records for the high and low scores have been broken. Easiest way for me was to ...